package com.server.dao;

import com.server.pojo.Alarm;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface AlarmDao extends JpaRepository<Alarm,Integer> {
    List<Alarm> findByIdIn(List<Integer> ids);

//    @Query("SELECT a FROM Alarm a WHERE UNIX_TIMESTAMP(a.alarmAt) + (a.duration / 1000) > CURRENT_TIMESTAMP")
//    List<Alarm> notExpired();
//
    @Query("SELECT a FROM Alarm a WHERE a.alarmAt >= CURRENT_TIMESTAMP - (a.duration / 1000) and SIZE(a.nowMobileApps) > 0")
    List<Alarm> needPush();
//    @Where(clause = "(UNIX_TIMESTAMP(alarm_at) + (duration / 1000)) > UNIX_TIMESTAMP(NOW())")
//    List<Alarm> findAll();

}
